class Solution {
    public List<String> buildArray(int[] target, int n) {
        Stack<Integer> stack = new Stack<>();
        List<String> list = new ArrayList<>();
        int j = 0;//代表target的下标
        for(int i = 1; i <= n; i++){
            if(j < target.length){
                stack.push(i);
                list.add("Push");
            }
            if(j < target.length && stack.peek() != target[j]){
                stack.pop();
                list.add("Pop");
                j--;
            }
            j++;
        }
        return list;
    }
}


